package com.song.cloud.order.controller;


import com.song.cloud.common.entities.CommonResult;
import com.song.cloud.common.entities.Payment;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RestTemplate;

/**
 * @Author ZhangGuisong
 * @Date 2021/2/13-12:27
 */
@RestController
public class OrderController {
//    public  static String  uri="http://localhost:8001";
    public final  static String uri="http://CLOUD-PROVIDER-SERVICE";
    @Autowired
    private RestTemplate restTemplate;
    @GetMapping("/consumer/save")
    public CommonResult<Payment> save(Payment payment){

        return restTemplate.postForObject(uri+"/payment/save",payment,CommonResult.class);
    }
    @GetMapping("/consumer/query/{id}")
    public CommonResult<Payment> query(@PathVariable("id") Long id){
        return restTemplate.getForObject(uri+"/payment/query/"+id,CommonResult.class);
    }
}
